import java.util.Arrays;

/**
 * @ClassName AdjustArray
 * @Description 调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序。
 * 如数组：[1,2,3,4,5,6]
 * 调整后可能是：[1, 5, 3, 4, 2, 6]
 * @Author 李明忠
 * @Date 2025/5/20 17:32
 * @Version 1.0
 */
public class AdjustArray {
    /**
     * [1,2,3,4,5,6]
     * [1,2,3,4,5,6]
     *  dest
     * @param array
     */
    public static int[] adjust(int[] array) {
        int[] arr = new int[array.length];
        int left = 0;
        int right = array.length-1;
        for (int i = 0; i < array.length; i++) {
            if (array[i] %2 != 0) {
                arr[left++] = array[i];
            } else {
                arr[right--] = array[i];
            }
        }
        return arr;
    }

    public static void main(String[] args) {
        int[] array = {1,2,3,4,5,6};
        array = adjust(array);
        System.out.println(Arrays.toString(array));
    }
}
